<?php

class System_Form_Problem extends Zend_Form
{

    public function init()
    {
        $this->setName('problem_form');
        parent::init();
        
        $this->setAttrib('enctype', 'multipart/form-data');
        
        $hidden = new Zend_Form_Element_Hidden('id');
        $this->addElement($hidden);
        
        
        $file = new Zend_Form_Element_File('file');
        $file->setLabel('Выберите файл')
                ->addValidator('Size', false, 1024000)
                ->addValidator('Extension', false, 'cpp,c,cs,java,pas');
        $this->addElement($file);
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Отправить');
        $this->addElement($submit);
        
    }
    
    public function addElement($element, $name = null, $options = null) {
        parent::addElement($element, $name, $options);
        
        if (!isset($name) || $name == null){
            $name = $element->getName();
        }
        
        if (isset($this->_elements[$name])) {
            $this->_elements[$name]->removeDecorator('Label');
            $this->_elements[$name]->removeDecorator('HtmlTag');
            $this->_elements[$name]->removeDecorator('DtDdWrapper');
            $this->_elements[$name]->removeDecorator('Description');
            $this->_elements[$name]->setAttrib('placeholder', $this->_elements[$name]->getLabel());
        }
    }
}

